/**   
 * Copyright 2011 COMERE Harold
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package etrl.shaders;

/**
 * \class GLSLType 
 * \brief Class describing a glsl type
 * 
 * @author harold
 * 
 */
public class GLSLType
{
	/**
	 * \enum Type \brief GLSL types enum
	 */
	public enum Type
	{
		VEC2, /** vec2 */
		VEC3, /** vec3 */
		VEC4, /** vec4 */
		MAT3, /** mat3 */
		MAT4, /** mat4 */
		INT, /** int */
		FLOAT, /** float */
		SAMPLER2D /** sampler2d */
	}

	/**
	 * glsl type
	 */
	private GLSLType.Type _type;

	/**
	 * String representing the glsl type
	 */
	private String _typeString;

	/**
	 * \brief Initializes the glsl type
	 * @param type
	 */
	public GLSLType(GLSLType.Type type)
	{
		_type = type;

		switch (type)
		{
		case VEC2:
			_typeString = "vec2";
			break;

		case VEC3:
			_typeString = "vec3";
			break;

		case VEC4:
			_typeString = "vec4";
			break;

		case MAT3:
			_typeString = "mat3";
			break;

		case MAT4:
			_typeString = "mat4";
			break;

		case SAMPLER2D:
			_typeString = "sampler2D";
			break;

		case INT:
			_typeString = "int";
			break;

		case FLOAT:
			_typeString = "float";
			break;

		default:
			_typeString = "__UNKNOWN__TYPE__";
			break;
		}
	}

	/**
	 * \brief Gets the glsl type
	 * @return glsl type
	 */
	public final GLSLType.Type getType()
	{
		return _type;
	}

	/**
	 * \brief Gets the string representing the glsl type
	 * @return glsl type string
	 */
	public final String asString()
	{
		return _typeString;
	}

	/**
	 * \brief Compares to glsl types
	 * @param otherType The glsl type to compare with
	 * @return true if the glsl types are the same, else false
	 */
	public boolean isEquals(GLSLType otherType)
	{
		return _type == otherType.getType();
	}

}
